<!DOCTYPE html>
<html lang="en">
<head>

	<meta charset="utf-8">
    <title>商品管理|商品列表</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    
    <!-- Le styles -->
    <link href="/cssadmin/bootstrap.css" rel="stylesheet">
    <link href="/cssadmin/font-awesome.css" rel="stylesheet">
    <link href="/cssadmin/admin.css" rel="stylesheet">
	<script src="/jsadmin/jquery.min.js"></script>
	<script src="/jsadmin/bootstrap.js"></script>
	<style>
		.disabled1{
			text-align: center;
		}
	</style>
    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
	    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

</head>    
<body>
<div class="container">	
	<div class="row">
		<div class="span2">
			<div class="main-left-col">
				<h1><i class="icon-shopping-cart icon-large"></i> Admin</h1>
				<ul class="side-nav">
					<li>
						<a href="{{url('admins/index')}}"><i class="icon-home"></i> 管理中心</a>
					</li>
					<li class="dropdown active">
						<a class="dropdown-toggle" data-toggle="collapse" data-target="#website-dropdown" href="#"><i class="icon-sitemap"></i> 商品管理 <b class="caret"></b></a>
						<ul id="website-dropdown">
							<li class="active"><a href="{{url('admins/glist')}}">商品列表</a></li>
							<li><a href="{{url('admins/clist')}}">商品分类</a></li>
							<li><a href="{{url('admins/gadd')}}">添加商品</a></li>
							<li><a href="{{url('admins/cadd')}}">添加分类</a></li>
							<li><a href="{{url('admins/grealdel')}}">回收站</a></li>
						</ul>
					</li>
					<li class="dropdown">
						<a class="dropdown-toggle" data-toggle="collapse" data-target="#store-dropdown" href="#"><i class="icon-shopping-cart"></i> 订单管理 <b class="caret"></b></a>
						<ul id="store-dropdown" class="collapse">
							<li><a href="{{url('order/wf')}}">订单列表(未付款)</a></li>
							<li><a href="{{url('order/ys')}}">订单列表(已付款)</a></li>
							<li><a href="{{url('order/yf')}}">订单列表(已发货)</a></li>
							<li><a href="{{url('order/end')}}">订单列表(已完成)</a></li>
						</ul>
					</li>
					<li class="dropdown">
						<a class="dropdown-toggle" data-toggle="collapse" data-target="#reports-dropdown" href="#"><i class="icon-signal"></i> 会员管理 <b class="caret"></b></a>
						<ul id="reports-dropdown" class="collapse">
							<li><a href="report.html">会员列表</a></li>
						</ul>
					</li>
					<li class="dropdown">
						<a class="dropdown-toggle" data-toggle="collapse" data-target="#report-dropdown" href="#"><i class="icon-file"></i> 素材管理 <b class="caret"></b></a>
						<ul id="report-dropdown" class="collapse">
							<li><a href="{{url('img/list')}}">图片空间</a></li>
							<li><a href="{{url('img/up')}}">上传图片</a></li>
						</ul>
					</li>
					<li class="dropdown">
						<a class="dropdown-toggle" data-toggle="collapse" data-target="#settings-dropdown" href="#"><i class="icon-cogs"></i> 权限管理 <b class="caret"></b></a>
						<ul id="settings-dropdown" class="collapse">
							<li><a href="{{url('admins/reg')}}">添加管理员</a></li>
							<li><a href="{{url('admins/adminlist')}}">管理员列表</a></li>
							<li><a href="{{url('admins/roleadd')}}">添加角色</a></li>
							<li><a href="{{url('admins/rolelist')}}">角色列表</a></li>
						</ul>
					</li>
				</ul>
			</div> <!-- end main-left-col -->
		</div> <!-- end span2 -->

<div class="span10">
	<div class="main-area dashboard">
		<div class="alert alert-info">
				<a class="close" data-dismiss="alert" href="#">x</a>
				<h4 class="alert-heading">提示信息</h4>
				The listing template can be used to list content that requires editing, such as pages, product catalogue, settings and members.
		</div>
	<div class="row">
		<div class="span10">
			<a href="{{url('admins/glist')}}" class="btn btn-danger">仓库中的商品</a>
			<a href="{{url('admins/gadd')}}" class="btn btn-success">添加新商品</a>
			<a href="{{url('admins/cadd')}}" class="btn btn-primary">增加新分类</a>
			<a href="{{url('admins/grealdel')}}" class="btn btn-default">回收站</a>
		</div>
		<div class="span10">
		<div class="slate">
		<div class="page-header">
			<h2>商品列表</h2>
			<div class="btn-group">
				<a class="btn dropdown-toggle" data-toggle="dropdown" >
				    按分类查找
				<span class="caret"></span>
				</a>
				<ul class="dropdown-menu">
					@foreach($catlist as $cat)
						<li class="disabled1">{{$cat['cat_name']}}</li>
						@foreach($cat['sbu'] as $caterzi)
							@if($cat['cat_id'] == $caterzi['parent_id'])
								<li><a href="{{url('admins/glist',['cat_id'=>$caterzi['cat_id']])}}">--{{$caterzi['cat_name']}}</a></li>
							@endif
						@endforeach
					@endforeach
					<script>
						$(document).ready(function(){
							$('.disabled1').prop('disabled',true);
						});
					</script>
				</ul>
			</div>
		</div>
		<table class="orders-table table">
			<thead>
				<tr>
					<th>编号</th>
					<th>商品名称</th>
					<th>商品货号</th>
					<th>分类</th>
					<th>价格</th>
					<th>上架</th>
					<th>精品</th>
					<th>热销</th>
					<th>库存</th>
					<th class="actions">操作</th>
				</tr>
			</thead>
			<tbody>
				@foreach($goods as $g)
				<tr>
					<td>{{$g->gid}}</td>
					<td><a href="#">{{$g->goods_name}}</a></td>
					<td>{{$g->goods_sn}}</td>
					<td>{{$g->cat_name}}</td>
					<td>{{$g->shop_price/100}}</td>
					<td id="sale{{$g->gid}}">@if($g->is_on_sale ==1)<i class="icon-ok"></i>@elseif($g->is_on_sale ==0)<i class="icon-remove"></i>@endif</td>
					<td id="best{{$g->gid}}">@if($g->is_best ==1)<i class="icon-ok"></i>@elseif($g->is_best ==0)<i class="icon-remove"></i>@endif</td>
					<td id="hot{{$g->gid}}">@if($g->is_hot ==1)<i class="icon-ok"></i>@elseif($g->is_hot ==0)<i class="icon-remove"></i>@endif</td>
					<td>{{$g->goods_number}}</td>
					<td class="actions dele">
						<a class="btn btn-small btn-danger delet" data-toggle="modal" href="{{url('admins/gdel',['gid'=>$g->gid])}}">删除</a>
						<a class="btn btn-small @if($g->is_on_sale==1)btn-info @else btn-primary disabled @endif" data-toggle="modal" href="" id="sales{{$g->gid}}">@if($g->is_on_sale==1)下架 @else 上架 @endif</a>
						<a class="btn btn-small @if($g->is_best==1)btn-success @else btn-primary disabled @endif" data-toggle="modal" href="" id="besta{{$g->gid}}"><i class="icon-thumbs-up"></i></a>
						<a class="btn btn-small @if($g->is_hot==1)btn-info @else btn-primary disabled @endif" data-toggle="modal" href="" id="hots{{$g->gid}}">Hot</a>
						<a class="btn btn-small btn-primary" href="{{url('admins/gedit',['gid'=>$g->gid])}}">修改</a>
					</td>
				</tr>
				<script>
					$(document).ready(function(){
						//加精操作
						$('#besta{{$g->gid}}').click(function(){
							if($('#best{{$g->gid}}').html() == '<i class="icon-ok"></i>'){
								//为正时将字段改为0
								$.get('{{url('admins/best',['id'=>$g->gid,'ok'=>1])}}',function(e){
									if(e == 1){
										$('#best{{$g->gid}}').html('<i class="icon-remove"></i>');
										$('#besta{{$g->gid}}').addClass('disabled');
										$('#besta{{$g->gid}}').removeClass('btn-success');
										$('#besta{{$g->gid}}').addClass('btn-primary');
									}else{
										alert(e);
									}
								});
							}else{
								$.get('{{url('admins/best',['id'=>$g->gid,'ok'=>0])}}',function(e){
									if(e == 1){
										$('#best{{$g->gid}}').html('<i class="icon-ok"></i>');
										$('#besta{{$g->gid}}').removeClass('disabled');
										$('#besta{{$g->gid}}').removeClass('btn-primary');
										$('#besta{{$g->gid}}').addClass('btn-success');
									}else{
										alert(e);
									}
								});
							}
						});

						//加热操作
						$('#hots{{$g->gid}}').click(function(){
							if($('#hot{{$g->gid}}').html() == '<i class="icon-ok"></i>'){
								//为正时将字段改为0
								$.get('{{url('admins/hot',['id'=>$g->gid,'ok'=>1])}}',function(e){
									if(e == 1){
										$('#hot{{$g->gid}}').html('<i class="icon-remove"></i>');
										$('#hots{{$g->gid}}').addClass('disabled');
										$('#hots{{$g->gid}}').removeClass('btn-info');
										$('#hots{{$g->gid}}').addClass('btn-primary');
									}else{
										alert(e);
									}
								});
							}else{
								$.get('{{url('admins/hot',['id'=>$g->gid,'ok'=>0])}}',function(e){
									if(e == 1){
										$('#hot{{$g->gid}}').html('<i class="icon-ok"></i>');
										$('#hots{{$g->gid}}').removeClass('disabled');
										$('#hots{{$g->gid}}').removeClass('btn-primary');
										$('#hots{{$g->gid}}').addClass('btn-info');
									}else{
										alert(e);
									}
								});
							}
						});
						//上下架操作
						$('#sales{{$g->gid}}').click(function(){
							if($('#sale{{$g->gid}}').html() == '<i class="icon-ok"></i>'){
								//为正时将字段改为0
								$.get('{{url('admins/sale',['id'=>$g->gid,'ok'=>1])}}',function(e){
									if(e == 1){
										$('#sale{{$g->gid}}').html('<i class="icon-remove"></i>');
										$('#sales{{$g->gid}}').addClass('disabled');
										$('#sales{{$g->gid}}').removeClass('btn-info');
										$('#sales{{$g->gid}}').addClass('btn-primary');
										$('#sales{{$g->gid}}').html('上架');
									}else{
										alert('没有权限');
									}
								});
							}else{
								$.get('{{url('admins/sale',['id'=>$g->gid,'ok'=>0])}}',function(e){
									if(e == 1){
										$('#sale{{$g->gid}}').html('<i class="icon-ok"></i>');
										$('#sales{{$g->gid}}').removeClass('disabled');
										$('#sales{{$g->gid}}').removeClass('btn-primary');
										$('#sales{{$g->gid}}').addClass('btn-info');
										$('#sales{{$g->gid}}').html('下架');
									}else{
										alert('没有权限');
									}
								});
							}
						});
					});
				</script>
				@endforeach
			</tbody>
		</table>
	</div>
</div>
	<div class="span5">
		<div class="pull-left">
		{!! $goods->render() !!}
		</div>
	</div>
</div>		
	<div class="row">
		<div class="span10 footer">
			<p>&copy; Web2016</p>
		</div>
	</div>
</div>
	
	</div> <!-- end span10 -->
		
	</div> <!-- end row -->
		
</div> <!-- end container -->

<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->

</body>
</html>